function Overlay(options) {
    TMap.DOMOverlay.call(this, options);
}

Overlay.COLORS = [
    '#0094FF',
    '#FD35A3', '#CF5E00', '#4EAD00', '#7E8600', '#C834FF', '#6D61FF', '#01B373', '#AD6F01', '#890202', '#70BDD0',
    '#FD01FC', '#020180', '#EE817E', '#CFB28A', '#82027E', '#01FDFD', '#FFB90F', '#8CBA89', '#03CCCF', '#028C8B',
    '#D86FD3', '#FD8901', '#9BCB34', '#21AFA8', '#C51786', '#6A59CB', '#FC6246', '#ABFD31', '#556A32', '#E8947B',
    '#FD35A3', '#CF5E00', '#4EAD00', '#7E8600', '#C834FF', '#6D61FF', '#01B373', '#AD6F01', '#890202', '#70BDD0',
    '#FD01FC', '#020180', '#EE817E', '#CFB28A', '#82027E', '#01FDFD', '#FFB90F', '#8CBA89', '#03CCCF', '#028C8B',
    '#D86FD3', '#FD8901', '#9BCB34', '#21AFA8', '#C51786', '#6A59CB', '#FC6246', '#ABFD31', '#556A32', '#E8947B',
    '#FD35A3', '#CF5E00', '#4EAD00', '#7E8600', '#C834FF', '#6D61FF', '#01B373', '#AD6F01', '#890202', '#70BDD0',
    '#FD01FC', '#020180', '#EE817E', '#CFB28A', '#82027E', '#01FDFD', '#FFB90F', '#8CBA89', '#03CCCF', '#028C8B',
    '#D86FD3', '#FD8901', '#9BCB34', '#21AFA8', '#C51786', '#6A59CB', '#FC6246', '#ABFD31', '#556A32', '#E8947B'
];

Overlay.prototype = new TMap.DOMOverlay();

// 初始化
Overlay.prototype.onInit = function (options) {
    this.position = options.position;
    this.className = options.className || '';
    this.title = options.title || '';
    this.content = options.content || '';
    this.offsetX = options.offsetX || -20;
    this.offsetY = options.offsetY || -50;
    this.onClick = options.onClick;
};

// 销毁时需解绑事件监听
Overlay.prototype.onDestroy = function () {
    if (this.onClick) {
        this.dom.removeEventListener('click', this.onClick);
    }
};

// 创建DOM元素，返回一个DOMElement，使用this.dom可以获取到这个元素
Overlay.prototype.createDOM = function () {
    var dom = document.createElement("div");
    dom.style.cssText = "position:absolute;";
    dom.className = this.className;
    dom.title = this.title;
    dom.innerHTML = this.content;
    dom.addEventListener("click", this.onClick);
    return dom;
};

// 更新DOM元素，在地图移动/缩放后执行
Overlay.prototype.updateDOM = function () {
    if (!this.map) {
        return;
    }

    // 经纬度坐标转容器像素坐标
    var pixel = this.map.projectToContainer(this.position);
    var divStyle = this.dom.style;
    divStyle.left = (pixel.getX() + this.offsetX) + "px";
    divStyle.top = (pixel.getY() + this.offsetY) + "px";
};

window.Overlay = Overlay;